﻿//
// Created by Administrator on 2020/9/15.
//
#include <iostream>
#include <string>


class RuntimeException : public std::exception {
private:
    int code;
    std::string message;
public:
    inline int getCode() const {
        return code;
    }

    inline std::string getMessage() {
        return message;
    }

    RuntimeException(int code, const char *message) : code(code), message(message) {
    }

    ~RuntimeException() {
        std::cout << "deconstruct" << std::endl;
    }
};

int main() {

    try {
        std::cout << "ExceptionTest" << std::endl;
        throw RuntimeException(500, "ERROR");
    } catch (RuntimeException &ex) {
        std::cout << "ERROR:" << ex.getCode() << ":" << ex.getMessage() << std::endl;
    }

    return 0;
}